package com.wtwd.campus.send;

import com.wtwd.campus.common.Constants;
import com.wtwd.campus.entity.Command;
import com.wtwd.campus.entity.MqAppInstallationSwitch;
import com.wtwd.campus.entity.MqMessage;

/**
 * @author mjy
 * @date 2022/12/15
 * @description
 */
public class SetAppInstallation implements Sender {

    @Override
    public Command dealMessage(MqMessage mqMessage) {
        MqAppInstallationSwitch mqAppInstallationSwitch = (MqAppInstallationSwitch) mqMessage.getObject();
        String content = "*".concat(Constants.MANUFACTURER_NAME).concat(",").concat(mqAppInstallationSwitch.getImei()).concat(",").concat(Constants.APP_INSTALLATION).concat(",")
                .concat(mqAppInstallationSwitch.getCommandNumber()).concat(",").concat(String.valueOf(mqAppInstallationSwitch.getOnOff())).concat("#");
        Command command = new Command();
        command.setImei(mqAppInstallationSwitch.getImei());
        command.setContent(content);
        command.setCmd(Constants.APP_INSTALLATION);
        command.setStatus(Constants.COMMAND_NEED_SAVE);
        command.setCommandNumber(mqAppInstallationSwitch.getCommandNumber());
        return command;
    }
}
